package com.example.cookbook.adapter;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import java.util.List;

public class MyFragmentAdapter extends FragmentPagerAdapter {
    private final List<Fragment> fragmentList2;

    public MyFragmentAdapter(FragmentManager fm, List<Fragment> fragmentList2) {
        super(fm);
        this.fragmentList2 = fragmentList2;
    }

    // 根据位置返回当前的碎片
    @Override
    public Fragment getItem(int i) {
        return fragmentList2.get(i);
    }

    // 碎片的总数
    @Override
    public int getCount() {
        return fragmentList2.size();
    }
}